<link rel='stylesheet' href='${rc.getContextPath()}/manage/styles/colorPicker/spectrum.css' />
<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet" type="text/css">
<script src="${rc.getContextPath()}/manage/styles/colorPicker/spectrum.js" type="text/javascript"></script>
<style>
dl.defectLookup span.error {
	position: absolute !important;
	left: 257px;
}

.sp-dd {
	background:
		url("${rc.getContextPath()}/manage/styles/dwz/themes/default/images/button/imgX.png");
	background-position: -163px -1px;
	height: 18px;
	width: 16px;
	position: absolute;
	right: 0px;
	top: 0px;
	border: 1px solid #D9DFE5;
}

.sp-replacer {
	padding: 0px;
	border: 0px !important;
	background: #EDF4F5 none repeat scroll 0% 0%;
	width: 146px;
	height: 24px;
	position: relative;
}

.sp-replacer.sp-active {
	border-color: #289BE5;
}

.sp-container, .sp-palette-container {
	border-color: #BDD7E7;
}

.sp-input {
	border: 1px solid #D9DFE5;
}

.sp-preview {
	width: 127px;
	height: 22px;
	border: 1px solid #D9DFE5;
	margin: 0px;
}
</style>
<div class="pageContent">
	<form method="post" action="${rc.getContextPath()}/manage/andonType/saveAndonType" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);">
		<div class="pageFormContent">
			<input type="hidden" name="navTabId" value="${navTabId!''}"> <input type="hidden" name="id"<#if pattern=='modify'>value="${andonType.andonTypeCode!''}"</#if>">
			<fieldset>
				<dl>
					<dt style="width: 120px;"><@label key="andonTypeCode.C,colon">ANDON类型编号</@label></dt>
					<dd>
						<input name="andonTypeCode" size="22" type="text" maxlength="20" class="required  alphanumeric toUp" warn="<@label key='andonTypeCode.C,alreadyExists'>缺陷编号已存在</@label>" value="${andonType.andonTypeCode!''}"<#if pattern=="modify"> readonly="readonly" <#else> remote="${rc.getContextPath()}/manage/andonType/validateAndonType" </#if> />
					</dd>
				</dl>
				<dl>
					<dt style="width: 120px;"><@label key="andonTypeText.C,colon">ANDON类型描述</@label></dt>
					<dd>
						<input name="typeText" size="22" type="text" maxlength="60" class="required" value="${andonType.typeText!''}" />
					</dd>
				</dl>
				<dl class="defectLookup">
					<dt style="width: 120px;"><@label key="status.C,colon">状态</@label></dt>
					<dd>
						<select name="lockFlag">
							<option value="0"<#if andonType.lockFlag?? && andonType.lockFlag == 0>selected="selected"</#if>><@label key="enable.C">启用</@label></option>
							<option value="1"<#if andonType.lockFlag?? && andonType.lockFlag == 1>selected="selected"</#if>><@label key="disable.C">禁用</@label></option>
						</select>
					</dd>
				</dl>
				<dl>

				</dl>
				<dl style="height: 40px;">
					<dt style="width: 120px;"><@label key="normalColor.C,colon">正常状态颜色</@label></dt>
					<dd>
						<input type='text' id="normalColor" name="normalColor" value="${andonType.normalColor!'#00FF00'}" />
					</dd>
				</dl>
				<dl style="height: 40px;">
					<dt style="width: 120px;"><@label key="touchColor.C,colon">触发状态颜色</@label></dt>
					<dd>
						<input type='text' id="touchColor" name="touchColor" value="${andonType.touchColor!'#FF0000'}" />
					</dd>
				</dl>
			</fieldset>
			<div class="panel">
			<h1><@label key="customAttribute.C">自定义属性</@label></h1>
			<div class="panelContent">
				<#if "read"!=pattern>
				<div id="andonAttributeBar" class="pBar">
					<ul class="toolBar">
						<input id="attributeCode" type="hidden" name="andonAttributeLookup.attributeCode" type="text" />
						<input id="attributeText" type="hidden" name="andonAttributeLookup.attributeText" type="text" />
						<input id="valueTypeEcode" type="hidden" name="andonAttributeLookup.valueTypeEcode" type="text" />
						<input id="memo" type="hidden" name="andonAttributeLookup.memo" type="text" />
						<li><a class="add" width="750" height="350" href="${rc.getContextPath()}/manage/andonAttribute/selectAndonAttribute?navTabId=${navTabId!''}" rel="selecandonAttribute" lookupGroup="andonAttributeLookup" callback="andonTypeJs.andonAttribute_callback" title="<@label key='addAndonAttribute.D'>新增ANDON属性</@label>"><span> <@label key='add.B'>新增</@label></span> </a></li>
						<li><a href="javascript:" class="delete" onclick="andonTypeJs.andonAttributedel()"><span><@label key="delete.B">删除</@label></span> </a></li>
					</ul>
				</div>
				</#if>

				<table id="andonAttributeTable" class="table border canopration" width="100%"
					<#if "modify"==pattern>layoutH="340"<#else>layoutH="270"</#if>>
					<thead>
                                            <tr>
                                            <th width="22"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
							                <th width="100"><@label key="andonAttributeCode.C">ANDON属性编号</@label></th>
							                <th width="100"><@label key="andonAttributeText.C">ANDON属性描述</@label></th>
							                <th width="100"><@label key="type.C">类型</@label></th>
                                            </tr>
                                        </thead>
                                        <tbody id="andonAttributeBody">
                                            <#if andonType.andonAttributes??> <#if (andonType.andonAttributes?size>0)><#list andonType.andonAttributes as andonAttribute>
                                            <tr id="andonAttribute_${andonAttribute.attributeCode!''}" target="andonAttribute_attributeCode" rel="${andonAttribute.attributeCode!''}">
                                                <td width="16"><input type="checkbox" name="ids" class="checkboxCtrl" value="${andonAttribute.attributeCode!''}">
                                                </td>
								                <td>${andonAttribute.attributeCode!''}</td>
								                <td>${andonAttribute.attributeText!''}</td>
								                <td>
								                    <#list ECode as eCode>
								                            <#if eCode.eCode==andonAttribute.valueTypeEcode>
								                            ${eCode.eCodeText!''}
								                            </#if>
								                    </#list>
								                </td>
                                            </tr>
                                            </#list><#else>
                                                <#if "read"==pattern>
                                                <tr>
                                                    <td colspan="4" class="noData">======<@label key='noListData.C'>列表无数据</@label>=====</font></td>
                                                </tr>
                                                </#if>
                                            </#if></#if>
                                        </tbody>
                                    </table>
			</div>
		</div>
		</div>
		
        <#if andonType??>
            <#assign createInfo=andonType>
            <#include "/common/createInfo.html">
        </#if>

<div class="formBar">
	<ul>
		<li>
			<div class="buttonActive">
				<div class="buttonContent">
					<button type="submit" onclick="andonTypeJs.check()"><@label key="save.B">保存</@label></button>
				</div>
			</div>
		</li>
		<li>
			<div class="buttonActiveGrey">
				<div class="buttonContent">
					<button type="button" class="close"><@label key="cancel.B">取消</@label></button>
				</div>
			</div>
		</li>
	</ul>
</div>
</form>
</div>
<script>
	$(function() {
		var dialog = $.pdialog.getCurrent();
		var normalColor = $("#normalColor", dialog);
		var touchColor = $("#touchColor", dialog);
		var colorOption = {
			chooseText: "<@label key='select.C'>选择</@label>",
			cancelText: "<@label key='cancel.B'>取消</@label>",
			showInput: true,
			preferredFormat: "hex",
			showInput: true,
			showPalette: true,
			palette: [["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
				["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
				["#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#cfe2f3", "#d9d2e9", "#ead1dc"],
				["#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#9fc5e8", "#b4a7d6", "#d5a6bd"],
				["#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6fa8dc", "#8e7cc3", "#c27ba0"],
				["#c00", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3d85c6", "#674ea7", "#a64d79"],
				["#900", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#0b5394", "#351c75", "#741b47"],
				["#600", "#783f04", "#7f6000", "#274e13", "#0c343d", "#073763", "#20124d", "#4c1130"]]
		};

		normalColor.spectrum(colorOption);
		touchColor.spectrum(colorOption);
		$('.sp-dd', dialog).empty();
	});

	var andonTypeJs = {
		check: function() {
			$('#andonAttributeBody input[name="ids"]').attr("checked", true);
		},
		andonAttribute_callback: function() {
			var attributeCode = $("#andonAttributeBar #attributeCode").val();
			var attributeText = $("#andonAttributeBar #attributeText").val();
			var valueTypeEcode = $("#andonAttributeBar #valueTypeEcode").val();

			var idArr = new Array();
			var nameArr = new Array();
			var typeArr = new Array();
			var memoArr = new Array();
			idArr = attributeCode.split(',');
			nameArr = attributeText.split(',');
			typeArr = valueTypeEcode.split(',');
			var ht = "";
			for (var i = 0; i < idArr.length; i++) {
				var id = idArr[i];
				var name = nameArr[i];
				var type = typeArr[i];

				var my_element = $("#andonAttribute_" + id);
				if (my_element.length == 0) {
					if(typeof(memo) == "undefined"){
						memo="";
					}
					ht += "<tr id='andonAttribute_"+id+"'target='andonAttribute_attributeCode' rel='"+id+"'><td width='20'><input  name='ids' value='"+id+"' type='checkbox'></td><td width='100'>"
						+ id + "</td><td width='100'>" + name + "</td><td width='100'>" + type + "</td></tr>";
				}

			}
			$("#andonAttributeBody").append(ht);
			$.jTableTool.initGridColumnWidth($("#andonAttributeTable"));

		},
		andonAttributedel: function() {
			var count = 0;
			$('input[name="ids"]:checked').each(function(i, e) {
				count++;
			});
			if (count == 0) {
				alertMsg.warn('<@label key="selectAndonAttribute.M">请勾选ANDON属性！</@label>')
			} else {
				alertMsg.confirm("<@label key='confirmDelAndonAttribute.M'>确认要删除选择的ANDON属性吗？</@label>", {
					okCall: function() {
						$('input[name="ids"]:checked').each(function(i, e) {
							$("#andonAttribute_" + e.value + '').remove();
							$.jTableTool.initGridColumnWidth($("#andonAttributeTable"));
						});
					}
				});
			}
		}
	}
</script>
